﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Net;
using SilverlightPicasa.Picasa;
using System.Windows.Media.Imaging;

namespace SilverlightPicasa
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        private void btn_Click(object sender, RoutedEventArgs e)
        {
            PicasaSoapClient psc = new PicasaSoapClient();
            psc.GetAlbumsCompleted += new EventHandler<GetAlbumsCompletedEventArgs>(psc_GetAlbumsCompleted);
            psc.GetAlbumsAsync(txtUser.Text);
        }

        void psc_GetAlbumsCompleted(object sender, GetAlbumsCompletedEventArgs e)
        {
            if (e.Error == null) lstAlbum.ItemsSource = e.Result;
        }

        private void lstAlbum_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Album obj= lstAlbum.SelectedItem as Album;
            albumThumbnail.Source = new BitmapImage(new Uri(obj.Thumbnail_Url));
        }

    }
}
